<!--#include file="p1.asp" -->
<%
Easp.NoCache
%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="dist/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="dist/layuiadmin/style/admin.css" media="all">
<style>
	.layui-input {height:24px}
	.layui-container {
		width: 100%;
	}
	.layui-btn {height:32px;padding: 0 12px;line-height: 32px; }	
	
.layui-footer {
    position: fixed;
    right: 0;
    bottom: 0;
    height: 44px;
    line-height: 44px;
    padding: 0 15px;
    background-color: #eee;
}	
</style> 
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>  
<script type="text/javascript">
		//功能：将回车键转tab键
        jQuery(function () {
            jQuery('input:text:first').focus();
            var $inp = jQuery('input:text');
            $inp.bind('keydown', function (e) {
                var key = e.which;
                if (key == 13 || key == 40 || key==38) 
				{
					e.preventDefault();
					if(key==38){
						var nxtIdx = $inp.index(this) - 1;
					
					}else{
						var nxtIdx = $inp.index(this) + 1;
					}
					//alert($(":input:text:eq(" + $inp.index(this) + ")").attr("name"));
					var iname=$(":input:text:eq(" + $inp.index(this) + ")").attr("name");
					var ival=$(":input:text:eq(" + $inp.index(this) + ")").val();
					var s="";
					var flag=false;
					$.ajaxSettings.async = false;				
					$.post(layui.setter.base + 'lib/reg.asp?action=bi0_regu1', {fld:iname, tn: "<%=val("table_name")%>"},
					   function(data){
							if(data=="<yyyy/mm/dd>"){
								if(ival.length==8)
								{
									$.post(layui.setter.base + 'lib/reg.asp?action=bi0', {ivalue:ival, fld:iname, tn: "<%=val("table_name")%>"}
									,function(data){
										s=data;
									});
									ival=s;
								}
								flag = isDate(ival);
							}
							else
							{
								flag=true;
							}
							if(flag==false)
							{
								layer.msg("日期格式或内容不正确！");
							}
					   });				
					$.ajaxSettings.async = true;
					if(flag==true)
					{
						if(s != ""){
							$(":input:text:eq(" + $inp.index(this) + ")").val(s);	
						}
						jQuery(":input:text:eq(" + nxtIdx + ")").focus();
					}
                }
            });
        }); 

	function isDate(ival)
	{
		var flag;
		var date = new Date(ival);
		var s1= date.getDate().toString();
		//alert(s1);
		if(s1=="NaN"){
			flag=false;
		}else{
			flag=true;
		}	
		return flag;
	}
    </script>
</head>
<body>
<div class="layui-container layui-col-space10">
<div class="layui-col-md3">
<%
dim db_path
db_path= Easp.Fso.MapPath("./")
if request("key") = "db" then
	session("dbName") = request("dbName")
	session("dbstr") = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Password=;Data Source="&db_path&"\dbs\" & request("dbName") & ".mdb"
	session("dbtype") = "access"
end if
conn()
conn2()




' temp()
col2()
vas "dbinfo",easp.db.sel("select * from dbs where dbName={dbName}")("dbinfo")

%>
<br>

	<table width="600" border="0" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC" class="layui-table">
			<tr><td>当前库：<font color=red><%=session("dbName")%></font></td></tr>
<%
	echo "<tr><td><a href='wtab.asp' class='layui-btn'" &">返回</a></td></tr>"

	if val("str")<>"" then
		echo "<tr><td><a href='?key=db&dbName=" &session("dbName") &"'>创建新表</a></td></tr>"
	end if

	dim objSchema,table_name,primarykey
	dim url,tnum
	set objSchema = Conn.OpenSchema(adSchemaTables)
	tnum=1
	Do While Not objSchema.EOF
		if objSchema("TABLE_TYPE") = "TABLE" then
%>
			<tr> <td>
			<%
				table_name=objSchema("TABLE_NAME")

				primarykey="ID"
				if easp.var("str")="manage" then			
					 echo "<a href='?key=view&table_name="& objSchema("TABLE_NAME") &"'>" & objSchema("TABLE_NAME") & "</a><br>"
				else
					echo "<a id="& da("tnum"&cstr(tnum)) &" href='?key=sql&sql=select * from " & table_name &  " where (1=1) order by id&table_name=" & table_name & "&primarykey=" & primarykey &"'>"& table_name &" </a>"
				end if
			%>
			</td></tr>
	<%
			if tnum=1 then
				vas "patTotal",easp.db.select(conn2,"select count(*) from " & table_name)(0)
				url="http://epi.yjk99.in/dzps/ct1.asp?key=sql&sql=select * from " & table_name & " where (1=1) order by id&table_name=" & table_name & "&primarykey=" & primarykey 
			end if
			tnum=tnum+1
		end if
		objSchema.MoveNext
	Loop

	if 	session("access")=1 then
		session("access")=0
		Response.Redirect(url)			
	end if
	%>
			<tr><td>共有病例数：<font color=red><%=val("patTotal")%></font></td></tr>
	
	</table>
	<div class="layui-card">
  <div class="layui-card-header">项目简介</div>
  <div class="layui-card-body">
<%echo val("dbinfo")
%>
  </div>
</div>
</div>
<div class="layui-col-md7">
<%
	select case request("key")
	case "db" '显示主界面
	  call main(val("str"))
	case "addtable" '显示创建表界面
	  call add_table(request("table_name"),request("field_num"))
	case "createtable" '执行创建表
	  call create_table()
	case "view"
	  call view(request("table_name"))
	case "sql"
	  ' call main("1")
	  call exesql(trim(request("sql")))
	case "addfield"
	  call addfield()
	case "editfidlevi"
	  call view(request("table_name"))
	case "editfidle"
	  call editfidle()
	case "exit"
	  session("dbtype") = ""
	  session("dbstr") = ""
	  response.redirect "?"
	case "edit"
	  call EditData2()
	case "reobj"
	  call reobj()
	case "conci"
	  call conci()
	end select
%>
<div class="layui-col-md7">
<div class="layui-footer">
<%
i_h "table_name",val("table_name")
echo val("table_name")
%>
</div>
</div>
</div>
</div>

  <script src="dist/layuiadmin/layui/layui.js"></script>
  <script>
  layui.config({
    base: 'dist/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'contlist', 'table','form','upload','layer'], function(){
    var $ = layui.$
    ,admin = layui.admin
    ,form = layui.form,upload = layui.upload,layer=layui.layer;
	form.render(); //更新全部
	form.render('select'); //刷新select选择框渲染

$("#demo1").on('click', function(){
	layer.prompt({title: '请输入编号(NUMB)：', formType: 0}, function(text, index){
		$.post('p2.asp?now=' + new Date().getTime(), {
			table_name:"<%echo val("table_name")%>",
			numb: text,
			action: "numb"
		},
		function(data) {
			if (data == '1') {
				layer.confirm('成功！', {skin: 'layui-layer-molv' ,title:'提示'}, function(index){
				window.location.href=document.URL;  

			});
			} else {
				layer.alert("失败！！ "+data, {
				  skin: 'layui-layer-molv' //样式类名
				  ,shadeClose: true, closeBtn: 0
				});				
			}
		});
		layer.close(index);
      });
});	
	
	
form.verify({
  username: function(value, item){ //value：表单的值、item：表单的DOM对象
    if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
      return '用户名不能有特殊字符';
    }
    if(/(^\_)|(\__)|(\_+$)/.test(value)){
      return '用户名首尾不能出现下划线\'_\'';
    }
    if(/^\d+\d+\d$/.test(value)){
      return '用户名不能全为数字';
    }
  }
  
  //我们既支持上述函数式的方式，也支持下述数组的形式
  //数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
  ,pass: [
    /^[\S]{6,12}$/
    ,'密码必须6到12位，且不能出现空格'
  ] 
}); 
	
  //拖拽上传
  upload.render({
    elem: '#test10'
    ,url: 'upload.asp?dbName=<%=easp.var("dbName")%>'
    ,accept: 'file' //普通文件
    //,exts: 'zip|rar|7z|pdf|qes' //允许上传
    ,done: function(res){
      alert(res);
	  console.log(res);
    }
  });	
    var table = layui.table;
    var active = {
      addtable:function(){
	    alert("abc");
		var table_name=$("#table_name").val();
		location.href = '?key=addtable&field_num=1&table_name='+table_name;
	  }
    }  
    $('.layui-btn.layuiadmin-btn-tags').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
  
  });
  </script>
</body>
</html>